-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improvements to cyclic checking, avoidance, named parameters #1186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -156,16 +156,24 @@ object Checking { | |||
tp | |||
} | |||
|
|||
def apply(tp: Type) = tp match { | |||
private def apply(tp: Type, cycleOK: Boolean, nestedCycleOK: Boolean): Type = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call these parameters overrideCycleOK
or cycleOKOverride
to avoid confusion with the class fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I picked the same names intentionally. I think there's also value in making clear they are the same.
/sync |
/rebuild |
This seems to be stuck in the validator. How can this be made unstuck? |
/synch |
@SethTisue : any idea what we can do to unstuck the build? |
@odersky : you could always do |
@smarter OK, that has helped. |
* | ||
* C[type T], D[type U] | ||
* | ||
* Then do you expand `C & D` to `[T, U] -> C[T, U] & D[T, U]` or not? Under the named |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean [T, U] -> C[T] & D[U]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or actually what we would do for unnamed tparams is [T] -> C[T] & D[T]
in such a case.
Simplified logic and now check prefixes of TypeRefs. Without the simplified logic we would get false cyclic errors for ski.scala. Test case: flowops.scala Fixes scala#1185.
The previous formulation broke for named parameters. Test case in flowops1.scala.
vcInlineMethods could produce a different type on rewire which led to a -Ycheck failure. We now insert a cast when that happens. Test case: pos/flowops1.scala with -Ycheck:vcInline.
Type was printed in raw form.
The intent is that Repr implementations should not bind the Out parameter.
Explicitly given type parameters were printed twice.
Add methods for expressing what the named type parameters of a class or type are. Also, add a method that widens a type so that is has a specified set of named type parameters.
When instantiating a type variable, make the instance has the same named type parameters as the upper bound. This is the analogue of kind-correctness for named type parameters.
Do it only if at least one of the types has unnamed parameters. This is a fundamental conflict with how we deal with intersections and unions.
No need to form the glb.
We should not return a ClassInfo as a value type.
Also: In a TypeMap, the variance of the prefix is unchanged (was: always 0). This brings it in line with TypeAccumulator and the subtyping rules.
Now verifies that the named type parameters of an overriding type or class are the same as the named type parameters of an overridden type.
Rebased to master |
Ready for review now. This has turned out to be somewhat a grab-bag of features but overall we got some good simplifications in addition to fixing type inference for named parameters. |
override final def namedTypeParams(implicit ctx: Context): Set[TypeSymbol] = { | ||
def computeNamedTypeParams: Set[TypeSymbol] = | ||
if (ctx.erasedTypes || is(Module)) Set() // fast return for modules to avoid scanning package decls | ||
else memberNames(abstractTypeNameFilter).map(name => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we create a NameFilter
instance that filters named type params directly instead?
object namedTypeParamNameFilter extends NameFilter {
def apply(pre: Type, name: Name)(implicit ctx: Context): Boolean =
name.isTypeName && {
val mbr = pre.member(name)
mbr.symbol.is(Deferred | TypeParam, butNot = ExpandedName) &&
mbr.info.isInstanceOf[RealTypeBounds]
}
}
Fixes #1185